manifest_path: Option<String>,
update_remotes: bool,
jobs: Option<uint>,
+ target: Option<String>,
release: bool,
}
update: options.update_remotes,
env: env,
shell: shell,
- jobs: options.jobs
+ jobs: options.jobs,
+ target: options.target.as_ref().map(|t| t.as_slice()),
};
ops::compile(&root, opts).map(|_| None).map_err(|err| {
let source_id = SourceId::for_git(&url, reference.as_slice());
- let mut config = try!(Config::new(shell, true, None).map_err(|e| {
+ let mut config = try!(Config::new(shell, true, None, None).map_err(|e| {
CliError::from_boxed(e, 1)
}));
let mut source = GitSource::new(&source_id, &mut config);
update: options.update,
env: "test",
shell: shell,
- jobs: options.jobs
+ jobs: options.jobs,
+ target: None,
};
try!(ops::compile(&root, compile_opts).map(|_| None::<()>).map_err(|err| {
pub update: bool,
pub env: &'a str,
pub shell: &'a mut MultiShell,
- pub jobs: Option<uint>
+ pub jobs: Option<uint>,
+ pub target: Option<&'a str>,
}
pub fn compile(manifest_path: &Path, options: CompileOptions) -> CargoResult<()> {
- let CompileOptions { update, env, shell, jobs } = options;
+ let CompileOptions { update, env, shell, jobs, target } = options;
+ let target = target.map(|s| s.to_string());
log!(4, "compile; manifest-path={}", manifest_path.display());
let source_ids = package.get_source_ids();
let (packages, resolve) = {
- let mut config = try!(Config::new(shell, update, jobs));
+ let mut config = try!(Config::new(shell, update, jobs, target.clone()));
let mut registry =
try!(PackageRegistry::new(source_ids, override_ids, &mut config));
target.get_profile().get_env() == env
}).collect::<Vec<&Target>>();
- let mut config = try!(Config::new(shell, update, jobs));
+ let mut config = try!(Config::new(shell, update, jobs, target));
try!(ops::compile_targets(env.as_slice(), targets.as_slice(), &package,
&PackageSet::new(packages.as_slice()), &resolve, &mut config));
debug!("compile_targets; targets={}; pkg={}; deps={}", targets, pkg, deps);
- let path_fragment = uniq_target_dest(targets);
- let target_dir = pkg.get_absolute_target_dir().join(path_fragment.unwrap_or(""));
+ let target_dir = pkg.get_absolute_target_dir()
+ .join(config.target().unwrap_or(""))
+ .join(uniq_target_dest(targets).unwrap_or(""));
let deps_target_dir = target_dir.join("deps");
let output = try!(util::process("rustc").arg("-v").exec_with_output());
.cwd(pkg.get_root())
.env("OUT_DIR", Some(cx.dest.as_str().expect("non-UTF8 dest path")))
.env("DEPS_DIR", Some(cx.dest.join(cx.deps_dir)
- .as_str().expect("non-UTF8 deps path")));
+ .as_str().expect("non-UTF8 deps path")))
+ .env("TARGET", cx.config.target());
for arg in cmd {
p = p.arg(arg);
}
into.push("-o".to_string());
into.push(out.join(target.get_name()).display().to_string());
}
+
+ match cx.config.target() {
+ Some(target) => {
+ into.push("--target".to_string());
+ into.push(target.to_string());
+ }
+ None => {}
+ }
}
fn build_deps_args(dst: &mut Args, package: &Package, cx: &Context) {
update_remotes: bool,
shell: &'a mut MultiShell,
jobs: uint,
+ target: Option<String>,
}
impl<'a> Config<'a> {
pub fn new<'a>(shell: &'a mut MultiShell,
update_remotes: bool,
- jobs: Option<uint>) -> CargoResult<Config<'a>> {
+ jobs: Option<uint>,
+ target: Option<String>) -> CargoResult<Config<'a>> {
if jobs == Some(0) {
return Err(human("jobs must be at least 1"))
}
update_remotes: update_remotes,
shell: shell,
jobs: jobs.unwrap_or(os::num_cpus()),
+ target: target,
})
}
self.update_remotes
}
- pub fn jobs(&mut self) -> uint {
+ pub fn jobs(&self) -> uint {
self.jobs
}
+
+ pub fn target<'a>(&'a self) -> Option<&'a str> {
+ self.target.as_ref().map(|t| t.as_slice())
+ }
}
#[deriving(Eq,PartialEq,Clone,Encodable,Decodable)]